<?php

namespace app\admin\model\cms;

use think\Model;
use traits\model\SoftDelete;

class IntroduceModel extends Model
{

    use SoftDelete;

    

    // 表名
    protected $name = 'introduce';
    
    // 自动写入时间戳字段
    protected $autoWriteTimestamp = 'integer';

    // 定义时间戳字段名
    protected $createTime = 'createtime';
    protected $updateTime = 'updatetime';
    protected $deleteTime = 'deletetime';

    // 追加属性
    protected $append = [

    ];


    public function admin()
    {
        return $this->belongsTo('app\admin\model\Admin', 'admin_id', 'id')->field('id,username,nickname,avatar');
    }

    // 定义多对一关联关系，获取所属栏目
    public function channels(){
        return $this->belongsTo(Channels::class, 'channels_id', 'id')->field('id,parent_id,correlation_id,name');
    }
}
